package com.aidex.biz.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.biz.domain.MonthDeptDetials;
import com.aidex.biz.service.MonthDeptDetialsService;
import com.aidex.common.utils.SecurityUtils;

/**
 * 月报项目详情Controller
 * @author sean
 * @email 2074844820@qq.com
 * @date 2025-01-20
 */
@RestController
@RequestMapping("/biz/bizMonthDeptDetials")
public class MonthDeptDetialsController extends BaseController
{
    @Autowired
    private MonthDeptDetialsService monthDeptDetialsService;

    /**
     * 查询月报项目详情列表
     */
    @GetMapping("/list")
    public R<PageInfo> list(MonthDeptDetials monthDeptDetials, HttpServletRequest request, HttpServletResponse response)
    {
        monthDeptDetials.setPage(new PageDomain(request, response));
        return R.data(monthDeptDetialsService.findPage(monthDeptDetials));
    }

    /**
     * 获取月报项目详情详细信息
     */
    @GetMapping(value = "/{id}")
    public R<MonthDeptDetials> detail(@PathVariable("id") String id)
    {
        return R.data(monthDeptDetialsService.get(id));
    }

    /**
     * 新增月报项目详情
     */
    @Log(title = "月报项目详情", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  MonthDeptDetials monthDeptDetials)
    {
        return R.status(monthDeptDetialsService.save(monthDeptDetials));
    }

    /**
     * 修改月报项目详情
     */
    @Log(title = "修改月报项目详情", businessType = BusinessType.UPDATE)
    @PostMapping("/batchUpdate")
    public R batchUpdate(@RequestBody @Validated  List<MonthDeptDetials> monthDeptDetials)
    {
        return R.status(monthDeptDetialsService.batchUpdate(monthDeptDetials));
    }

    /**
     * 修改月报项目详情
     */
    @Log(title = "月报项目详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated MonthDeptDetials monthDeptDetials)
    {
        return R.status(monthDeptDetialsService.save(monthDeptDetials));
    }


    /**
     * 删除月报项目详情
     */
    @Log(title = "月报项目详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(monthDeptDetialsService.deleteMonthDeptDetialsByIds(ids));
    }

    /**
     * 获取最大编号
     */
    @GetMapping("/findMaxSort")
    public R findMaxSort()
    {
        return R.data(monthDeptDetialsService.findMaxSort(new MonthDeptDetials()));
    }

    /**
     * 导出月报项目详情列表
     */
    @Log(title = "月报项目详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(MonthDeptDetials monthDeptDetials)
    {


        List<MonthDeptDetials> list = monthDeptDetialsService.findList(monthDeptDetials);
        ExcelUtil<MonthDeptDetials> util = new ExcelUtil<MonthDeptDetials>(MonthDeptDetials.class);
        return util.exportExcel(list, "月报项目详情数据");
    }

}
